home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1 / lisp / mac / dumptime.el < prev    next >
Encoding:
Text File  |  1994-05-18  |  3.8 KB  |  125 lines  |  [TEXT/EMAC]

  1. ;;;
  2. ;;; This file is part of a Macintosh port of GNU Emacs.
  3. ;;; Copyright (C) 1993, 1994 Marc Parmet.  All rights reserved.
  4. ;;;
  5. ;;; GNU Emacs is distributed in the hope that it will be useful,
  6. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  8. ;;; GNU General Public License for more details.
  9. ;;;
  10.  
  11. ;;;
  12. ;;; The following files are included in the dump.
  13. ;;;
  14. ;;; Any file that includes a call to AEInstallEventHandler or menu traps must not be
  15. ;;; included in a dump, but instead be executed at each startup.
  16. ;;;
  17.  
  18. (load "mac/ctypes")
  19. (load "mac/utils")
  20. (load "mac/headers")
  21. (load "mac/traps")
  22. (load "mac/Memory")
  23. (load "mac/Resources")
  24. (load "mac/Fonts")
  25. (load "mac/Quickdraw")
  26. (load "mac/Events")
  27. (load "mac/Windows")
  28. (load "mac/Controls")
  29. (load "mac/Dialogs")
  30. (load "mac/Colors")
  31. (load "mac/Menus")
  32. (load "mac/Processes")
  33. (load "mac/GestaltEqu")
  34. (load "mac/Desk")
  35. (load "mac/Scrap")
  36. (load "mac/OSUtils")
  37. (load "mac/Palettes")
  38. (load "mac/AppleEvents")
  39. (load "mac/clipboard")
  40. (load "mac/mouse")
  41. (load "mac/about")
  42. (load "mac/stacksize")
  43. (load "mac/modifiers")
  44. (load "mac/color-edit")
  45.  
  46. (autoload 'ispell "ispell" nil t)
  47. (autoload 'ispell-word "ispell" nil t)
  48. (define-key esc-map "$" 'ispell-word)
  49.  
  50. (defvar available-menu-ID 128)
  51.  
  52. (defun get-unique-menu-ID ()
  53.   (prog1
  54.       available-menu-ID
  55.     (setq available-menu-ID (1+ available-menu-ID))))
  56.  
  57. ;;; We redefine this function to make it stationery-aware.
  58.  
  59. (defun find-file-noselect (filename &optional nowarn)
  60.   "Read file FILENAME into a buffer and return the buffer.
  61. If a buffer exists visiting FILENAME, return that one,
  62. but verify that the file has not changed since visited or saved.
  63. The buffer is not selected, just returned to the caller."
  64.   (setq filename (expand-file-name filename))
  65.   ;; Get rid of the prefixes added by the automounter.
  66.   (if (and (string-match automount-dir-prefix filename)
  67.        (file-exists-p (file-name-directory
  68.                (substring filename (1- (match-end 0))))))
  69.       (setq filename (substring filename (1- (match-end 0)))))
  70.   (if (file-directory-p filename)
  71.       (if find-file-run-dired
  72.       (dired-noselect filename)
  73.     (error "%s is a directory." filename))
  74.     (let ((buf (get-file-buffer filename))
  75.       error)
  76.       (if buf
  77.       (or nowarn
  78.           (verify-visited-file-modtime buf)
  79.           (cond ((not (file-exists-p filename))
  80.              (error "File %s no longer exists!" filename))
  81.             ((yes-or-no-p
  82.               (if (buffer-modified-p buf)
  83.               "File has changed since last visited or saved.  Flush your changes? "
  84.             "File has changed since last visited or saved.    Read from disk? "))
  85.              (save-excursion
  86.                (set-buffer buf)
  87.                (revert-buffer t t)))))
  88.     (save-excursion
  89.           ;;; Added
  90.       (let* ((spec (make-string (c:sizeof 'FSSpec) 0))
  91.          (err (unix-filename-to-FSSpec filename spec))
  92.          (have-stationery (and (zerop err) (ae-is-stationery spec))))
  93.         
  94.         (setq buf (if have-stationery
  95.               (generate-new-buffer "untitled")
  96.             (create-file-buffer filename)))
  97.         (set-buffer buf)
  98.         (erase-buffer)
  99.         (condition-case ()
  100.         (insert-file-contents filename (not have-stationery))
  101.           (file-error
  102.            (setq error t)
  103.            ;; Run find-file-not-found-hooks until one returns non-nil.
  104.            (let ((hooks find-file-not-found-hooks))
  105.          (while (and hooks
  106.                  (not (funcall (car hooks))))
  107.            (setq hooks (cdr hooks))))))
  108.         (setq default-directory (file-name-directory filename))
  109.         (funcall
  110.          (if have-stationery (function stationery-after-find-file)
  111.            (function after-find-file))
  112.          error (not nowarn)))))
  113.       buf)))
  114.  
  115. (defun stationery-after-find-file (&optional error warn)
  116.   (setq buffer-read-only nil)
  117.   (if noninteractive
  118.       nil
  119.     (if auto-save-default
  120.     (auto-save-mode t)))
  121.   (set-buffer-modified-p nil)
  122.   (mapcar 'funcall find-file-hooks))
  123.  
  124. (provide 'mac-dumptime)
  125.